﻿using System;
using System.Threading;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;


namespace ProjectNocturnalFool
{
    /// <summary>
    /// draws the TileImages based on the "GameLogic.GameBoardLogic.getTiles()" TileSet
    /// 
    /// </summary>
    class EntityDrawer
    {
        #region Fields
        public List<EntitySprite> entitySprites;

        #endregion
        #region Constructor
        public EntityDrawer()
        {
            entitySprites = new List<EntitySprite>();
            for (int i = 0; i < GameLogic.Instance.gameBoardLogic.entities.allEntities.Count; i++ )
            {
                entitySprites.Add(new EntitySprite(i));
            }
            
        }
        #endregion


        #region Methods-currently empty

        #endregion

        #region Draw + Update

        public void Draw(GameTime gameTime)
        {
            for (int i = 0; i < entitySprites.Count; i++) {
                entitySprites[i].Draw(gameTime);
            }
        }

        public void Update(GameTime gameTime) 
        {
            for (int i = 0; i < entitySprites.Count; i++)
            {
                entitySprites[i].Update(gameTime);
            }
        }

        public Point checkSpritesForMouseHover(Vector2 hloc) {
            Point retPt = new Point(-1,-1);
            for (int i = 0; i < entitySprites.Count; i++) {
                if (entitySprites[i].CheckForMouseHover(hloc) && entitySprites[i].onTile.Y >= retPt.Y) {
                    retPt = entitySprites[i].onTile;
                }
            }


            return retPt ;
            //return hpt;
        }

        #endregion

    }
}
